package com.epi.one.basic.log;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author dxy
 * @version 1.0
 */
public class ListenSocketApp {
    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(8088)) {
            System.out.println("Listening on port 8088...");
            while (true) {
                Socket client = serverSocket.accept();
                BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
                String line;
                while ((line = in.readLine()) != null) {
                    System.out.println("接收到消息：" + line);
                }
                client.close();
                System.out.println("Closing server...");
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
